/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ep.uc001.ui.views;

import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.ComponentContainer;
import com.vaadin.ui.Label;
import ep.libs.implementations.AbstractModule;
import ep.libs.implementations.AbstractView;
import ep.uc001.module.UC001Module;

/**
 *
 * @author Spyros
 */
public class UC001View extends AbstractView {

    private String argument;

    public UC001View(AbstractModule module) {
        super(module);
    }

    public UC001View(AbstractModule module, Object[] args) {
        super(module, args);
        if (args != null && args[0] != null) {
            argument = (String) args[0];
        }
    }

    @Override
    public ComponentContainer getView() {
        initializeComponents();
        return viewLayout;
    }

    private void initializeComponents() {
        String label = "uc001";
        if (argument != null) {
            label += " - " + argument;
        }
        viewLayout.addComponent(new Label(label));
        Button changeModuleButton = new Button("change to uc001");
        changeModuleButton.addListener(new Button.ClickListener() {

            @Override
            public void buttonClick(ClickEvent event) {
                module.getApplication().changeModule(UC001Module.class, new Object[]{"second"});
            }
        });

        viewLayout.addComponent(changeModuleButton);
    }
}
